package main

import (
	"fmt"

	"github.com/gin-gonic/gin"
)

func GlobalMiddleware1(c *gin.Context) {
	fmt.Println("global middleware 1 start")
	c.Next()
	fmt.Println("global middleware 1 end")
}

func GlobalMiddleware2(c *gin.Context) {
	fmt.Println("global middleware 2 start")
	c.Next()
	fmt.Println("global middleware 2 end")
}

func main() {
	r := gin.Default()
	r.Use(GlobalMiddleware1, GlobalMiddleware2)
	r.GET("/index", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "Hello World",
		})
	})
	r.Run(":9000")
}
